<template>
<h1>计算器练习</h1>
  <div style="width: 1000px;height: 1000px;">
    <input type="text" v-model="num1">
    <span>
    <button @click="calc('+')" >加</button>
  <button @click="calc('-')" >减</button>
  <button @click="calc('*')">乘</button>
  <button @click="calc('/')">除</button>
  </span>
    <input type="text" v-model="num2">

    <h4>={{result}}</h4>
  </div>


</template>

<script setup>
import {ref} from "vue";

const num1 = ref('');
const num2 = ref('');
const result = ref('')
const calc = (o)=>{
  result.value=eval(num1.value+o+num2.value);
}
</script>

<style scoped>

</style>